<template>
  <div class="adminqianming">
    <!-- <admin_top></admin_top> -->
    <div style="background: #6492CF;">
      <img src="https://cdn.91haoka.cn/houtailogo.png" style="height: 80px;">
    </div>
    <div style="padding: 0 20px;margin-top: 30px;">
      <el-table :data="tableData" style="text-align: center;" align="center" border >
        <el-table-column label="创建时间">
          <template slot-scope="scope">
            <span>{{ scope.row.created_at }}</span>
          </template>
        </el-table-column>
        <el-table-column label="充值商家">
          <template slot-scope="scope">
            <span>{{ scope.row.name }}</span>
          </template>
        </el-table-column>
        <el-table-column label="充值金额">
          <template slot-scope="scope">
            <span>{{ scope.row.amount }}</span>
          </template>
        </el-table-column>
        
        <el-table-column label="充值状态">
          <template slot-scope="scope">
            <span v-if="scope.row.status==0">待审核</span>
            <span v-if="scope.row.status==1">已充值</span>
          </template>
        </el-table-column>
        <el-table-column label="备注">
          <template slot-scope="scope">
            <span>{{ scope.row.remark }}</span>
          </template>
        </el-table-column>
        <el-table-column label="打款截图">
          <template slot-scope="scope">
            <img v-if="scope.row.payment_prove" :src="scope.row.payment_prove" alt="" @click="openimg(scope.row.payment_prove)" style="width: 100px;">
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button v-if="scope.row.status==0" type="text" @click="shenhe(scope.row.id)">确认充值</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- <div style="text-align: center;margin-top: 10px;padding-bottom: 10px;">
        <el-pagination
          @current-change="pagechange"
          background
          layout="prev, pager, next"
          :page-size="all.page_size"
          :total="total">
        </el-pagination>
      </div> -->
    </div>
    <el-dialog
      title="查看图片"
      :visible.sync="showimg"
      width="500">
      <img :src="nowimg" style="width: 100%;">
    </el-dialog>
  </div>
</template>

<script>
  import admin_top from './top.vue';
  import axios from 'axios'
  export default {
    components: {
      admin_top
    },
    name: 'adminqianming',
    data() {
      return {
        // all: {
        //   page_size: 20,
        //   page: 1,
        // },
        tableData: "",
        total:0,
        showimg:false,
        nowimg:''
      }
    },
    watch: {

    },
    computed: {

    },
    created() {
      this.getlist()
    },
    methods: {
      //打开图片
      openimg(url){
        this.nowimg = url
        // this.nowimg = 'http://test91.91haoka.cn/1679368811Nj7.jpg'
        this.showimg = true
      },
    
      //获取全部
      getlist: function() {
        var that = this
        axios.get('/api/plan-market/admin/offline/recharge/list',{
          params:this.all
        })
          .then(response => {
            if (response.data.msg.code == 0) {
              console.log(response.data)
              this.tableData = response.data.data
              // this.total = response.data.data.total
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
      },
      //翻页
      pagechange(val){

        this.all.page = val
        this.getlist()
      },
      //审核
      shenhe(id){
        console.log(id)
        this.$confirm('是否确认充值', '提醒', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          axios.post('/api/plan-market/admin/offline/recharge/review',{
            id:id,
          })
            .then(response => {
              if(response.data.msg.code == 0){
                this.$message({
                  type: 'success',
                  message: '操作成功!'
                });
                this.getlist()
              }else {
                this.$message.error(response.data.msg.info);
              }
              
            })
          
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          });          
        });
      }

    },

  }
</script>

<style scoped>
  .adminqianming {
    background: #EAEAEA;
    min-height: 100vh;
    padding: 0px;
  }
</style>
